package cc.customer.common.config;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;

/**
 * Description: customer
 * Created by yhsh on 2019/10/30 8:51
 * version 2.0
 * 方法说明
 */
public class SocketIOConfig {

	/*private final static Logger logger = LoggerFactory.getLogger(SocketIOConfig.class);

	@Value("${spring.socketio.host}")
	private String host;

	@Value("${spring.socketio.port}")
	private Integer port;

	@Value("${spring.socketio.bossCount}")
	private int bossCount;

	@Value("${spring.socketio.workCount}")
	private int workCount;

	@Value("${spring.socketio.allowCustomRequests}")
	private boolean allowCustomRequests;

	@Value("${spring.socketio.upgradeTimeout}")
	private int upgradeTimeout;

	@Value("${spring.socketio.pingTimeout}")
	private int pingTimeout;

	@Value("${spring.socketio.pingInterval}")
	private int pingInterval;

	*//**证书位置**//*
	@Value("${spring.socketio.ssl.sslLocation}")
	private String sslLocation;
	*//**证书密码**//*
	@Value("${spring.socketio.ssl.sslPassword}")
	private String sslPassword;*/

	/**
	 * 以下配置在上面的application.properties中已经注明
	 * @return
	 */
	/*@Bean
	public SocketIOServer socketIOServer() {
		SocketConfig socketConfig = new SocketConfig();
		socketConfig.setTcpNoDelay(true);
		socketConfig.setSoLinger(0);
		com.corundumstudio.socketio.Configuration config = new com.corundumstudio.socketio.Configuration();
		config.setSocketConfig(socketConfig);
		config.setHostname(host);
		config.setPort(port);
		config.setBossThreads(bossCount);
		config.setWorkerThreads(workCount);
		config.setAllowCustomRequests(allowCustomRequests);
		config.setUpgradeTimeout(upgradeTimeout);
		config.setPingTimeout(pingTimeout);
		config.setPingInterval(pingInterval);

		config.setKeyStorePassword(sslPassword);
		config.setTransports(Transport.POLLING, Transport.WEBSOCKET);
		config.setOrigin(":*:");
		InputStream stream = null;
		try {
			stream = new FileInputStream(sslLocation);
		} catch (FileNotFoundException e) {
			logger.error("初始化socketIo 的证书失败: "+e.getMessage());
		}
		config.setKeyStore(stream);
		return new SocketIOServer(config);
	}*/
}
